package dfbz.homework1;

import java.util.ArrayList;

public class Test04 {
    public static void main(String[] args) {
        print();
    }
    private static void print(){
        ArrayList<String> list=new ArrayList<>();
        //添加4个元素:"孙悟空","猪八戒","沙和尚","铁扇公主"
        //获取索引为3的元素并打印
        list.add("孙悟空");
        list.add("猪八戒");
        list.add("沙和尚");
        list.add("铁扇公主");
        System.out.println("获取索引为三的元素是:"+list.get(3));
        //4. 修改索引为3的元素为"唐僧"
        list.set(3,"唐僧");
        list.remove(1);
        for (int i = 0; i <list.size() ; i++) {
            System.out.println(list.get(i));
        }
    }
}
